package binary_tree.leetcode;
import java.util.ArrayList;
import java.util.List;

/**
 * 二叉树的前序遍历
 * @Author Stark
 * @Date 2022/2/21 17:09
 */
public class Num144_PreOrder {
    List<Integer> list = new ArrayList<>();
    public List<Integer> preorderTraversal(TreeNode root) {
        if(root == null){
            return list;
        }
        list.add(root.val);
        preorderTraversal(root.left);
        preorderTraversal(root.right);
        return list;
    }
}
